package com.mrd.gtimpframe.action;

import com.mrd.exception.validation.MRDValidationException;
import com.mrd.framework.config.web.json.Result;
import com.mrd.framework.ui.Jqgrid;
import com.mrd.framework.ui.filter.SearchRule;
import com.mrd.framework.ui.filter.SearchRuleOption;
import com.mrd.framework.utils.HttpUtils;
import com.mrd.gtimp.business.entity.ContractTerms;
import com.mrd.gtimp.business.entity.Declaration;
import com.mrd.gtimp.business.entity.DeclarationAttachment;
import com.mrd.gtimp.business.service.*;
import com.mrd.gtimp.fix.ChnToCodeFix;
import com.mrd.gtimp.order.action.OrderAction;
import com.mrd.gtimp.v2.datalock.DataLockUtil;
import com.mrd.gtimpframe.entity.CompanyInfo;
import com.mrd.gtimpframe.entity.CustomCompanyInfo;
import com.mrd.gtimpframe.entity.DeclaRelastionship;
import com.mrd.gtimpframe.entity.RejectCount;
import com.mrd.gtimpframe.repository.CusInfoMapper;
import com.mrd.gtimpframe.service.CompanyInfoService;
import com.mrd.gtimpframe.service.DeclaRelastionshipService;
import com.mrd.gtimpframe.service.OriginalDeclarationBiz;
import com.mrd.gtimpframe.service.RejectCountService;
import com.mrd.redis.JedisClientClusterImpl;
import com.mrd.util.FreeMarkerUtils;
import com.mrd.util.GtimpBusinessUtil;
import com.mrd.util.LoginUtil;
import com.mrd.util.ValidationUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by zxk on 2018/1/8 代录单下单功能
 *
 */
@Controller
@RequestMapping("/business/agent/order")
public class AgentOrderController {
    /**
     * 页面操作状态存储的变量名(操作状态,insert,update)
     */
    public static final String OPSTATE_STRING = "opState";
    private static final Logger logger = LoggerFactory.getLogger(OrderAction.class);
    /**
     * 一般贸易，加工贸易状态存储的变量名()
     */
    public static final String TRADETYPE_STRING = "tradeType";
    @Resource
    private CusInfoMapper cusInfoMapper;
    @Resource
    private CompanyInfoService companyInfoService;
    @Resource
    private JedisClientClusterImpl jedisClientCluster;
    @Autowired
    public ChnToCodeFix chnToCodeFix;
    @Resource
    private RejectCountService rejectCountService;
    @Resource
    private DeclarationBiz declarationBiz;
    @Resource
    private DeclarationPortBiz declarationPortBiz;
    @Resource
    private DeclaRelastionshipService declaRelastionshipService;
    @Resource
    private ContractTermsBiz contractTermsBiz;
    @Resource
    private OriginalDeclarationBiz originalDeclarationBiz;
    @Resource
    private CompanyQpTempBiz companyQpTempBiz;
    @Resource
    private DataLockUtil dataLockUtil;
    @Resource
    private DeclarationAttachmentBiz declarationAttachmentBiz;
    /**
     * 下单页面
     */
    public static final String ORDER_DECLARE_PAGE = "/pendingEntryOrder";
    /**
     * 柜模板路径配置
     */
    @Value("${excel_container_model}")
    private String containerExcelTemplatePath;
    /**
     * 出口报关单模板路径配置
     */
    @Value("${excel_export_declaration_model}")
    private String exportDeclarationExcelTemplatePath;
    /**
     * 进口报关单模块路径配置
     */
    @Value("${excel_import_declaration_model}")
    private String importDeclarationExcelTemplatePath;

    @RequestMapping("/ft")
    public String ft(Model model, String type, String tradeType) {
        Declaration declaration = new Declaration();
        // 设置贸易类型
        if (StringUtils.isNotEmpty(tradeType)) {
            declaration.setTradeType(tradeType);
        } else {
            declaration.setTradeType(Declaration.TRADE_TYPE_GENERAL);
        }
        FreeMarkerUtils.prepareUseForFTL(declaration);
        String isCCI = HttpUtils.getParam("isCCI");
        if (isCCI != null) {
            declaration.setIsTongguanYth(isCCI);
        } else {
            declaration.setIsTongguanYth("0");
        }
        model.addAttribute("declaration", declaration);
        if (Declaration.DECLARATION_TYPE_ENTRY.equals(type)) {
            model.addAttribute("type", Declaration.DECLARATION_TYPE_ENTRY);
        } else {
            model.addAttribute("type", Declaration.DECLARATION_TYPE_EXPORT);
        }
        model.addAttribute(OPSTATE_STRING, OperatioState.insert);
        model.addAttribute("soState", false);
        return "/pendingEntryOrder";
    }
    /**
     * 代录单出口下单页面 - 加工贸易
     */
    @RequestMapping("/out/process")
    public String AgentOutDeclare(Model model) {
        return ft(model, Declaration.DECLARATION_TYPE_EXPORT, Declaration.TRADE_TYPE_Process);
    }
    /**
     * 代录单出口下单页面 - 一般贸易
     */
    @RequestMapping("/out/general")
    public String AgentOutDeclareGeneral(Model model) {
        return ft(model, Declaration.DECLARATION_TYPE_EXPORT, Declaration.TRADE_TYPE_GENERAL);
    }
    /**
     * 代录单进口下单页面 - 一般贸易
     */
    @RequestMapping("/in/general")
    public String AgentInDeclareGeneral(Model model) {
        return ft(model, Declaration.DECLARATION_TYPE_ENTRY, Declaration.TRADE_TYPE_GENERAL);
    }
    /**
     * 代录单进口下单页面 - 加工贸易
     */
    @RequestMapping("/in/process")
    public String AgentInDeclare(Model model) {
        return ft(model, Declaration.DECLARATION_TYPE_ENTRY, Declaration.TRADE_TYPE_Process);
    }
    /**
     * 页面操作状态
     */
    enum OperatioState {
        insert, update, read
    }
    /**
     * 暂存
     *
     * @param declaration 报关单
     */
    @RequestMapping("/save")
    @ResponseBody
    public Result save(Declaration declaration,HttpServletRequest request) {
        try {
            String did = declaration.getId();
            String enter_type=request.getParameter("isAgent");
            declaration.setEnter_page(enter_type);
            //为录单客户添加标记，直接下单或代录单
            String comId= LoginUtil.getLoginUser().getCompany().getId();
            CompanyInfo companyInfo=(CompanyInfo) companyInfoService.selectByPrimaryKey(comId);
            String companyType="0";
            if(StringUtils.isNoneEmpty(companyInfo.getType(),companyInfo.getIsAgent(),companyInfo.getIsDrectCust())) {//根据逻辑判断
                if(companyInfo.getIsDrectCust().equals("1") & companyInfo.getType().equals("CL") && companyInfo.getIsAgent().equals("1")) {
                    companyType = "1";
                }
            }
            declaration.setEnter_type(companyType);

            if (jedisClientCluster.get("lock_decla_" + declaration.getId(), String.class) != null) {
                return Result.newFailInstance("报关单已被锁定，解锁前不能进行操作");
            }
            if (declaration.getActionChain() == null || !declaration.getActionChain().endsWith("s2")) {
                declaration.setActionChain(Declaration.ChainModel.save, true);
            }
            chnToCodeFix.chnToCode(declaration);
            ValidationUtil.validate(declaration);
            GtimpBusinessUtil.formatContainerListAsContainerNoAndContainerNoShow(declaration);
            // GtimpBusinessUtil.checkCommodityValidity(declaration);
            RejectCount rejectCount = rejectCountService.selectByDid(declaration.getId());
            DeclaRelastionship declaRelastionship = null;
            if (rejectCount != null) {
                declaration = declarationBiz.rejectToNew(declaration, rejectCount.getCount() + "");
                if (rejectCount.getCount() == 1) {
                    declaRelastionship = new DeclaRelastionship(did);
                } else {
                    declaRelastionship = declaRelastionshipService.selectByDeclaId(did);
                    declaRelastionship.setParent(did);
                }
            }
            Declaration d = declarationBiz.save(declaration);
            // 如果是驳回过的单，建立报关单关系谱
            if (rejectCount != null) {
                declaRelastionship.setNode(d.getId());
                declaRelastionshipService.insertSelective(declaRelastionship);
            }
            if (StringUtils.isNotEmpty(d.getId())) {
                ContractTerms contractTerms = contractTermsBiz.findEntityByDeclaration(d);
                if (contractTerms == null) {
                    contractTerms = new ContractTerms();
                    contractTerms.setDeclaration(d);
                    contractTerms.setContract_total_chn(d.getTotal_money());
                    contractTerms.setContract_total_en(d.getTotal_money());
                    contractTerms.setCurrency_chn(d.getCommodities().get(0).getCurrency());
                    contractTerms.setCurrency_en(d.getCommodities().get(0).getCurrency());
                    contractTerms.setPrice_terms_chn(d.getDeal_mode());
                    contractTerms.setPrice_terms_en(d.getDeal_mode());
                    contractTerms.setPacking_chn(d.getGoods_package());
                    contractTerms.setLoading_port_chn(d.getGoods_addr());
                    contractTerms.setDestination_port_chn(d.getCommodities().get(0).getDestination());
                    contractTerms.setShipping_marks_chn(d.getCarton());
                    contractTermsBiz.saveOrupdateEntity(contractTerms);
                    d.setContract_terms_type("1");
                    d.setContractTerms(contractTerms);
                    d = declarationBiz.save(d);
                }
            }
            return Result.newSuccessInstance("保存成功!", d.getId());
        } catch (MRDValidationException e) {
            String msg = e.getMessage();
            String[] mses = msg.split(",");
            List<String> msList = new ArrayList<>();
            for (String mse : mses) {
                if (mse != null) {
                    msList.add(mse.trim());
                }
            }
            return Result.newFailInstance("数据校验错误!", msList);
        } catch (Exception e) {
            logger.error("暂存报关单出现错误", e);
            return Result.newFailInstance(e.getMessage());
        }
    }
    /**
     * 提交报关单
     */
    @RequestMapping("/submit")
    @ResponseBody
    public Result submit(Declaration declaration,HttpServletRequest request) {
        try {
            String enter_type=request.getParameter("isAgent");
            declaration.setEnter_page(enter_type);
            String rs = companyQpTempBiz.queryCompanyState(declaration.getCompany_co(), declaration.getCompany_name());
            //为录单客户添加标记，直接下单或代录单
            String comId= LoginUtil.getLoginUser().getCompany().getId();
            CompanyInfo companyInfo=(CompanyInfo) companyInfoService.selectByPrimaryKey(comId);
            String companyType="0";
            if(StringUtils.isNoneEmpty(companyInfo.getType(),companyInfo.getIsAgent(),companyInfo.getIsDrectCust())) {//根据逻辑判断
                if(companyInfo.getIsDrectCust().equals("1") & companyInfo.getType().equals("CL") && companyInfo.getIsAgent().equals("1"))
                    companyType = "1";
            }
            declaration.setEnter_type(companyType);
            if (StringUtils.isNotEmpty(rs) && rs.equalsIgnoreCase("fail")) {
                return Result.newFailInstance("收发货人为未审核状态，请等待审核后再提交!");
            } else if (StringUtils.isNotEmpty(rs) && rs.equalsIgnoreCase("reset")) {
                return Result.newFailInstance("请重新选择收发货人后再提交!");
            } else if (StringUtils.isEmpty(rs) || rs.equalsIgnoreCase("error")) {
                return Result.newFailInstance("收发货人查询错误，请联系管理员!");
            }
            rs = companyQpTempBiz.queryCompanyState(declaration.getFahuo_company_co(), declaration.getFahuo_company_name());
            if (StringUtils.isNotEmpty(rs) && rs.equalsIgnoreCase("fail")) {
                return Result.newFailInstance((Declaration.DECLARATION_TYPE_EXPORT.equals(declaration.getDeclaration_type()) ? "生产销售单位" : "消费使用单位") + "为未审核状态，请等待审核后再提交!");
            } else if (StringUtils.isNotEmpty(rs) && rs.equalsIgnoreCase("reset")) {
                return Result.newFailInstance("请重新选择收发货人后再提交!");
            } else if (StringUtils.isEmpty(rs) || rs.equalsIgnoreCase("error")) {
                return Result.newFailInstance("收发货人查询错误，请联系管理员!");
            }
            if (declaration.getActionChain() == null || !declaration.getActionChain().endsWith("S2")) {
                declaration.setActionChain(Declaration.ChainModel.submit, true);
            }
            chnToCodeFix.chnToCode(declaration);
            GtimpBusinessUtil.checkDeclaration(declaration);
            GtimpBusinessUtil.formatContainerListAsContainerNoAndContainerNoShow(declaration);
            Declaration d = declarationBiz.submit(declaration);
            // 第一手资料备份
            // originalDeclarationBiz.saveDeclarationAsOriginal(d.getId());

            /**
             * 优化 第一手资料备份异步保存
             *
             * @descript 提交单据的时候上面保存完就可以直接返回给用户，第一手资料做异步保存就行
             * @author han
             */
            String userId = LoginUtil.getLoginUser().getId();
            new Thread() {
                @Override
                public void run() {
                    originalDeclarationBiz.saveDeclarationAsOriginalByDidiUser(d.getId(), userId);
                }
            }.start();

            return Result.newSuccessInstance("提交成功!", d.getId());
        } catch (Exception e) {
            logger.error("提交报关单出现错误", e);
            return Result.newFailInstance("数据校验错误!", e.getMessage());
        }
    }
    /**
     * 客户从驳回修改页面提交报关单
     */
    @RequestMapping("/customerRejectSubmit")
    @ResponseBody
    public Result customerRejectSubmit(Declaration declaration,HttpServletRequest request) throws Exception {
        declaration.setState(Declaration.DeclarationBusinessState.DRAFT_STATE);
        declaration.setPayment_type("0");
        declaration.setBusinessId(declarationBiz.newBusinessKey());
        List<String> properties = new ArrayList<>();
        properties.add("state");
        properties.add("payment_type");
        properties.add("businessId");
        declarationBiz.updateEntity(declaration, properties);
        declaration.setRejectContents(null);
        return submit(declaration,request);
    }
    /**
     * 下载柜模板
     */
    @RequestMapping("/download/excel_container")
    @ResponseBody
    public void downloadContainerTemplate(HttpServletRequest request, HttpServletResponse response) {
        String basePath = request.getServletContext().getRealPath("/");
        String downloadFilePath = basePath + containerExcelTemplatePath;
        download(request, response, downloadFilePath, "报关单柜列表模板");
    }

    /**
     * 下载出口报关单模板
     */
    @RequestMapping("/download/excel_export_declaration")
    @ResponseBody
    public void downloadExportDeclarationTemplate(HttpServletRequest request, HttpServletResponse response) {
        String basePath = request.getServletContext().getRealPath("/");
        String downloadFilePath = basePath + exportDeclarationExcelTemplatePath;
        download(request, response, downloadFilePath, "出口报关单模板");
    }

    /**
     * 下载进口报关单模板
     */
    @RequestMapping("/download/excel_import_declaration")
    @ResponseBody
    public void downloadImportDeclarationTemplate(HttpServletRequest request, HttpServletResponse response) {
        String basePath = request.getServletContext().getRealPath("/");
        String downloadFilePath = basePath + importDeclarationExcelTemplatePath;
        download(request, response, downloadFilePath, "进口报关单柜列表模板");
    }
    /**
     * 设置让浏览器弹出下载对话框的Header. 根据浏览器的不同设置不同的编码格式 防止中文乱码
     *
     * @param fileName 下载后的文件名.
     */
    private void download(HttpServletRequest request, HttpServletResponse response, String downloadFilePath, String fileName) {
        File downFiles = new File(downloadFilePath);
        if (!downFiles.exists()) {
            return;
        }
        if (!fileName.contains(".") && downloadFilePath.contains(".")) {
            fileName += downloadFilePath.substring(downloadFilePath.lastIndexOf("."));
        }
        try (InputStream fis = new FileInputStream(downFiles); BufferedInputStream bis = new BufferedInputStream(fis); OutputStream fos = response.getOutputStream(); BufferedOutputStream bos = new BufferedOutputStream(fos)) {
            // 中文文件名支持
            String encodedFileName;
            String agent = request.getHeader("USER-AGENT");
            if (agent != null && agent.contains("MSIE")) {// IE
                encodedFileName = java.net.URLEncoder.encode(fileName, "UTF-8");
            } else if (agent != null && agent.contains("Mozilla")) {
                encodedFileName = new String(fileName.getBytes("UTF-8"), "iso-8859-1");
            } else {
                encodedFileName = java.net.URLEncoder.encode(fileName, "UTF-8");
            }
            response.setHeader("Content-Disposition", "attachment; filename=\"" + encodedFileName + "\"");
            response.setHeader("Content-Length", "" + downFiles.length());
            int byteRead;
            byte[] buffer = new byte[2048];
            while ((byteRead = bis.read(buffer, 0, 2048)) != -1) {
                bos.write(buffer, 0, byteRead);
            }
            bos.flush();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 修改报关单
     */
    @RequestMapping(value = "/update")
    public String update(Model model, @RequestParam String id) {
        if (StringUtils.isEmpty(id)) {
            model.addAttribute("soState", false);
            Object declaration = HttpUtils.getSession().getAttribute("OrderExcelModel_data");
            if (declaration != null) {
                FreeMarkerUtils.prepareUseForFTL(declaration);
                model.addAttribute("declaration", declaration);
                model.addAttribute("type", HttpUtils.getSession().getAttribute("OrderExcelModel_type"));
                model.addAttribute(OPSTATE_STRING, OperatioState1.update);
                return ORDER_DECLARE_PAGE;
            }
        }
        try {
            Declaration declaration = declarationBiz.findEntityById(id);
            declarationBiz.checkDeclareCanUpdate(declaration); // 非草稿状态不允许修改
            if (declaration != null) {
                dataLockUtil.lock("VDBS", id, LoginUtil.getLoginUser().getAccount() + LoginUtil.getLoginUser().getName());
                FreeMarkerUtils.prepareUseForFTL(declaration);
                model.addAttribute("declaration", declaration);
                model.addAttribute("type", declaration.getDeclaration_type());
                String portCode = declaration.getSupCompany().getPort_code();
                if (StringUtils.isNotEmpty(portCode)) {
                    boolean hasSO = declarationPortBiz.findHasSOByPortCode(portCode);
                    model.addAttribute("soState", hasSO);
                }
            }
            Declaration.sortCommidities(declaration);
            model.addAttribute(OPSTATE_STRING, OperatioState1.update);
        } catch (Exception e) {
            logger.warn("不能修改已提交的单证!操作人：{},操作单证：{}", LoginUtil.getLoginAccount(), id);
            Declaration declaration = new Declaration();
            declaration.setTradeType(Declaration.TRADE_TYPE_GENERAL);
            FreeMarkerUtils.prepareUseForFTL(declaration);
            Declaration.sortCommidities(declaration);
            model.addAttribute("declaration", declaration);
        }
        return ORDER_DECLARE_PAGE;
    }
    @RequestMapping("/declarationToPdf")
    public String declarationBackupToPdf(Model model, String originalId) {
        Declaration declaration = originalDeclarationBiz.getDeclarationFromOriginalId(originalId);
        FreeMarkerUtils.prepareUseForFTL(declaration);
        model.addAttribute("declaration", declaration);
        if (Declaration.DECLARATION_TYPE_ENTRY.equals(declaration.getType())) {
            model.addAttribute("type", Declaration.DECLARATION_TYPE_ENTRY);
        } else {
            model.addAttribute("type", Declaration.DECLARATION_TYPE_EXPORT);
        }
        model.addAttribute(OPSTATE_STRING, OperatioState1.insert);
        model.addAttribute("soState", false);
        model.addAttribute("pdfMode", true);
        return "/order";
    }
    /**
     * 报关单详情
     *
     * @param id 报关单id
     */
    @RequestMapping("/detail")
    public String detail(Model model, String id) {
        model.addAttribute(OPSTATE_STRING, OperatioState1.read);
        try {
            Declaration declaration = declarationBiz.findEntityById(id);
            if (declaration != null) {
                dataLockUtil.lock("VDBS", id, LoginUtil.getLoginUser().getAccount() + LoginUtil.getLoginUser().getName());
                FreeMarkerUtils.prepareUseForFTL(declaration);
                model.addAttribute("declaration", declaration);
                String isCCI = declaration.getIsTongguanYth();
                boolean isSecondSup = StringUtils.isNotEmpty(isCCI) && "1".equals(isCCI) && LoginUtil.getLoginUser().getCompany().getId().equals(declaration.getSecondSupId());
                model.addAttribute("isSecondSup", isSecondSup);
                model.addAttribute("type", declaration.getDeclaration_type());
                Declaration.sortCommidities(declaration);
                String portCode = declaration.getSupCompany().getPort_code();
                if (StringUtils.isNotEmpty(portCode)) {
                    boolean hasSO = declarationPortBiz.findHasSOByPortCode(portCode);
                    model.addAttribute("soState", hasSO);
                }

                /*** 详情查询附件，如果有附件，前端按钮显示可点，不然灰色(han) **/
                Jqgrid jqgrid = new Jqgrid();
                jqgrid.addRule(new SearchRule("bill_no", SearchRuleOption.eq, id));
                jqgrid.addOrder(Sort.Direction.DESC, "ctime");
                Page<DeclarationAttachment> attachments = declarationAttachmentBiz.findByJqgrid(jqgrid);
                if (attachments.getContent() != null && attachments.getContent().size() > 0) {
                    model.addAttribute("attachState", true);
                }
                /*待审核状态下，判断当前用户所属是否是签约报关行*/
                if (com.mrd.gtimpframe.entity.Declaration.DeclarationBusinessState.ORDER_STATE.equals(declaration.getState())) {
                    boolean isSign = "1".equals(LoginUtil.getLoginUser().getCompany().getIsSignWS());
                    model.addAttribute("isSignWS", isSign);
                }
            }
        } catch (Exception e) {
            Declaration declaration = new Declaration();
            declaration.setTradeType(Declaration.TRADE_TYPE_GENERAL);
            FreeMarkerUtils.prepareUseForFTL(declaration);
            Declaration.sortCommidities(declaration);
            model.addAttribute("declaration", declaration);
        }
        boolean isSupplier = false;
        try {
            isSupplier = "CC".equals(LoginUtil.getLoginUser().getCompany().getType());
        } catch (Exception e1) {
            e1.printStackTrace();
        }
        model.addAttribute("isSupplier", isSupplier + "");
        return ORDER_DECLARE_PAGE;
    }
    /**
     * 复制报关单
     *
     * @param id 待复制的报关单id
     */
    @RequestMapping(value = "/copy")
    public String copy(Model model, String id) {
        try {
            Declaration declaration = declarationBiz.copyDeclaration(id);
            if (declaration != null) {
                declaration.setSo("");
                declaration.setReport_date(new Date());
                FreeMarkerUtils.prepareUseForFTL(declaration);
                model.addAttribute("declaration", declaration);
                model.addAttribute("type", declaration.getDeclaration_type());
                declaration.clearActionChain();
                declaration.setActionChain(Declaration.ChainModel.copy, true);
                String portCode = declaration.getSupCompany().getPort_code();
                if (StringUtils.isNotEmpty(portCode)) {
                    boolean hasSO = declarationPortBiz.findHasSOByPortCode(portCode);
                    model.addAttribute("soState", hasSO);
                } else {
                    model.addAttribute("soState", false);
                }
            }
            Declaration.sortCommidities(declaration);
            model.addAttribute(OPSTATE_STRING, OperatioState1.insert);
        } catch (Exception e) {
            logger.warn("复制报关单失败，查询错误!操作人：{},操作单证：{}", LoginUtil.getLoginAccount(), id);
            Declaration declaration = new Declaration();
            declaration.setTradeType(Declaration.TRADE_TYPE_GENERAL);
            FreeMarkerUtils.prepareUseForFTL(declaration);
            Declaration.sortCommidities(declaration);
            model.addAttribute("declaration", declaration);
        }
        return ORDER_DECLARE_PAGE;
    }
    /**
     * 页面操作状态
     */
    enum OperatioState1 {
        insert, update, read
    }

}
